Repository navigation
Conversation
Verify the CPython, zlib and SQLite source tarballs by SHA-256 and carry the WASI patches that 3.14.10 does not include in cpython-patches/. Update zlib to 1.3.2 and SQLite to 3.54.1.
wit-component 0.258.3 counts a library's exports, including Wasm tags it does not write into the dlopen symbol table. A library exporting a tag, such as __c_longjmp from setjmp/longjmp support, then makes the loader read past its symbols. Carry wit-component with the one-line fix until it is released.
Lowering a Python value that does not match its WIT type used to panic part way through, for example with an out-of-range int. Check the whole value first: an import call raises TypeError, OverflowError or ValueError naming the argument before the host sees a call, and an export whose result does not match traps with a message naming the value.
The handle table holds a strong reference to an exported resource's Python object, but the destructor did nothing, so objects whose handles the host dropped were never finalized. Release the reference in the destructor, and drop the handle when an owned handle returns to the guest instead of leaking it.
An extension may depend on a shared library that is not itself an extension, such as libsetjmp.so or a libjpeg.so shipped next to it. Link each library that a linked library names in its dylink.0 needed list, from the Python path or the WASI SDK's libsetjmp.so, under the name its dependents use. Libraries that nothing needs are not linked.
noise64
force-pushed
the
runtime-baseline
branch
from
November 16, 2026 23:05
1cfe609 to
90cbde9
Compare
Pre-initialization saves the application's state into the component, so host entropy, time and file writes during it made each build different. Derive the hash seed and random bytes from the linked component, give the guest a clock that starts at the Unix epoch, stop it from writing bytecode into the source directories, and give the directories created for the build fixed times.
CPython defers a deallocation when its measured C stack margin is small, but on WebAssembly that margin covers only the linear-memory stack. Freeing a deeply nested list exhausted the engine's call stack first. Count nested deallocations instead and defer at depth 50.
CPython raises RecursionError when the linear-memory C stack is nearly full, but the engine's own call stack is separate and grows several times faster for the same C recursion. The --stack-size option, and stack_size in the library API, let the caller size the C stack so that RecursionError comes first for its engine's call stack.
setup-python has no 3.14.0 build for the current ubuntu-latest image, so the Test jobs failed before building. 3.14.10 is published for every runner in the matrix and matches the CPython release that the build uses.
noise64
force-pushed
the
runtime-baseline
branch
from
November 16, 2026 23:51
90cbde9 to
3cf6e79
Compare
build.rs reused an existing cpython/ without the release tarball, its checksum or the patches, and an existing libpython3.14.so without a build. A checkout that had built other sources packaged that older runtime. It now records the SHA-256 of the CPython, zlib and SQLite tarballs and of each patch in cpython/ and cpython/builddir/wasi, and fails on a tree or library with another identity or none.
The checks before lowering accepted only int and float instances, but the lowering takes any object with __index__ or __float__, such as numpy.int64. They now extract the value as the lowering does and keep the TypeError and OverflowError messages. Pre-initialization entropy came from the linked component alone, so every app without native extensions got the same hash seed and random bytes. It now also covers the app name and the files of each Python path entry. build.rs removes a partly patched CPython tree before extracting, and applies only *.patch files.
The dlopen symbol-count fix is merged into the golem-2.0 branch of golemcloud/wasm-tools. The patch now pins that commit instead of the vendored copy, which is removed. Its source is the same as the vendored copy, and its sibling crates still come from crates.io.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Touches GOL-1850 (PY-02): runtime repairs that the Golem Python SDK needs. It does not resolve the issue.
Runtime repairs for the Golem Python SDK, on top of upstream 5382383. This is the first of two stacked fork PRs; the second adds the persisted prepare/assemble API.
cpython-patches/carries the WASI patches that 3.14.10 does not include: dynamic linking (GH-142234),sys/ioctl.hinsocketmodule.c, and a deallocation depth bound (below). zlib moves to 1.3.2 and SQLite to 3.54.1.801650b(branchgolem-2.0), through[patch.crates-io]. The fork counts only the symbols that it writes, so the table size matches its entries when a library exports exception tags. The other 0.258.3 crates (wasmparser, wasm-encoder, wit-parser, wasm-metadata, wit-dylib) still come from crates.io. Builds now fetch the fork from GitHub.build.rsrecords the SHA-256 of the CPython sources: the release tarball, the name and content of each patch (line endings normalized), and the zlib and SQLite tarballs. It writes the identity tocomponentize-py-source-identityincpython/when it extracts and patches the tarball, and incpython/builddir/wasiwhen it linkslibpython3.14.so. The file name is not hidden, because the CI artifact upload leaves out hidden files. A library or tree without that identity, or with another one, fails the build, and the error tells you to deletecpython/. A partly patched tree from an interrupted build is removed before extraction, and only*.patchfiles incpython-patches/are applied. Before, an existingcpython/skipped the download, the checksum and the patches, and an existinglibpython3.14.soskipped the build. A warm checkout then packaged an older runtime. The CI artifactcpython/builddir/wasicarries the identity, so the Test jobs reuse the Populate build.TypeError,OverflowErrororValueErrorthat names the argument, and the host does not see a call. A bad export result traps with a message that names the export. Integer and float checks extract the value as the lowering does, sonumpy.int64and other objects with__index__or__float__pass. Before, out-of-range integers wrapped and a moved handle reached the host as handle 0. The threetrap_on_empty_*tests becomereject_moved_*: a second use of a moved handle now raisesValueErrorin the guest.dylink.0needed list and links the named support libraries from the Python path, orlibsetjmp.sofrom the WASI SDK. Before, an extension that used setjmp/longjmp failed to link.max_wasm_stack, deeprepr,json,pickleand Python__repr__recursion trapped before CPython raisedRecursionError.--stack-size(andstack_sizein the library API) sets the C stack. The default stays at the linker's 1 MiB, because the correct value depends on the engine. With 96 KiB on Golem's engine, every measured kind raisesRecursionError, at a lower depth._Py_Deallocand the trashcan count nested deallocations and defer past depth 50, because the stack-margin check does not see the engine's stack. Before, freeing a deeply nested list trapped.Known gaps:
--stack-sizeaccepts any value, including 0 or a value that is not a multiple of 16. The CPython cache identity does not cover the WASI SDK version or the configure and link recipe. The same owned handle passed twice in one call passes the check, and the host receives handle 0 for the second use.Not in this PR: cancellation and the asyncio functions that raise
NotImplementedError, Wasm exceptions on the Golem engine (needs exceptions in the shared engine), and a PyO3 extension that aborts on panic.Verification
On this head, 7389c59 (Linux x86_64, local):
cargo test --release -- --skip http_p3_example: passed (118 lib, 21 bindings, 9 componentize tests).bash .github/workflows/lint.sh: passed.libdl.soofvendor/wit-componentwere byte-identical to the wit-component crate of wasm-tools801650b.Cargo.lockchanges only by thesourceline of wit-component, and no crate name and version has two sources.build.rsidentity code as this branch. This branch adds the removal of a partly patched tree and the*.patchfilter; no case exercised these two. The wit-component change does not touchbuild.rs.cpython/withlibpython3.14.soand no identity fails before packaging, and the library is not changed.libpython3.14.sowith no identity file next to it fails the same way.cpython/andcpython/builddir/wasi.cpython/.cpython/builddir/wasirestored without hidden files, as the CI artifact does: the build reuses it, with no download.LOCAL_TARBALL_DIR, a local build.rs change that is not in this PR, read the SQLite tarball from a local copy, because sqlite.org is not reachable from the build machine; the checksum is still checked.http_p3_example, because its port is taken on the build machine.